Skip to content

fix(datasets): require pipeline options instead of substituting wrong defaults - #1413

Open
Maryyyyyyyam142 wants to merge 1 commit into
roboflow:developfrom
Maryyyyyyyam142:fix/N-dataset_builder_option_defaults
Open

fix(datasets): require pipeline options instead of substituting wrong defaults#1413
Maryyyyyyyam142 wants to merge 1 commit into
roboflow:developfrom
Maryyyyyyyam142:fix/N-dataset_builder_option_defaults

Conversation

@Maryyyyyyyam142

Copy link
Copy Markdown

Closes #1412
The four dataset builders derive the same image-pipeline options from args, but disagree on how. build_coco reads most of them directly; build_roboflow_from_coco, build_roboflow_from_yolo and build_o365_raw use getattr with literal fallbacks — five of which contradict the real config default:

option old fallback actual default
square_resize_div_64 False True (TrainConfig)
segmentation_head False True on every seg variant
multi_scale False True (TrainConfig)
expanded_scales False True (TrainConfig)
patch_size 16 variant-dependent — 12 seg/keypoint, 14 base
num_windows 4 2 on every released variant

patch_size and num_windows have no default on ModelConfig, so no constant is correct — and (16, 4) matches no shipped variant.

Change

All four builders now read these seven options directly, so an incomplete namespace raises AttributeError instead of silently building a different pipeline. do_random_resize_via_padding is included for cluster parity; its fallback already matched the default, so that one is a no-op.

The remaining getattr fallbacks are deliberately untouched — aug_config, scale_jitter and augmentation_backend match their config default, and the keypoint fields' absence is meaningful ("detection-only", per the existing comment at coco.py:1301).

Scope

Latent on the RFDETRDataModule path: _namespace_from_configs populates every field, so normal model.train(...) is unaffected. The exposure is the direct-call path, which the builders' re-export from rfdetr.datasets and the comment at coco.py:1318-1322 both document as supported.

Tests

New tests/datasets/test_builder_options.py covers the cross-builder contract:

  • each of the four builders raises on a namespace missing a pipeline option (fails on develop)
  • the configured values reach the transform builder — num_windows=2 not 4, multi_scale=True, seg variants at patch_size=12 with include_masks=True

Four tests in test_coco.py passed partial namespaces and relied on the old fallbacks. They now use a _pipeline_args helper that spells out the values those fallbacks used to produce, so their behavior is unchanged and what they depend on is visible.

674 passed across tests/datasets/ and src/rfdetr/datasets/. ruff, ruff format, docformatter and codespell pass on the changed files; mypy reports nothing in them.

… defaults

The dataset builders read the same image-pipeline options from `args`, but
`build_roboflow_from_coco`, `build_roboflow_from_yolo` and `build_o365_raw`
read them via `getattr` with literal fallbacks that contradict the real
config defaults, while `build_coco` reads most of them directly:

  square_resize_div_64  fallback False, TrainConfig default True
  segmentation_head     fallback False, True on every seg variant
  multi_scale           fallback False, TrainConfig default True
  expanded_scales       fallback False, TrainConfig default True
  patch_size            fallback 16,    variant-dependent (12/14/16)
  num_windows           fallback 4,     2 on every released variant

`patch_size` and `num_windows` have no default on `ModelConfig`, so no
constant is correct; the pair the builders chose, (16, 4), matches no
shipped variant. A caller passing an incomplete namespace — supported and
documented usage, since the builders are re-exported from `rfdetr.datasets`
— silently trained a different pipeline: multi-scale off, and a scale set of
[192..832] instead of [352..672] at resolution 512.

Read these seven options directly in all four builders so an incomplete
namespace fails loudly. The remaining `getattr` fallbacks are left alone:
their values match the config default, or the absence is meaningful
(keypoint fields absent means detection-only, per the comment at coco.py).

This is latent on the `RFDETRDataModule` path, where `_namespace_from_configs`
populates every field.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The contract tests only verify the first missing option and do not protect the remaining required fields.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Requires explicit dataset pipeline options to prevent silent, incorrect defaults in direct builder calls.

Changes:

  • Replaces fallback values with direct namespace access.
  • Adds cross-builder contract tests.
  • Updates existing tests with explicit pipeline arguments.
File summaries
File Description
src/rfdetr/datasets/coco.py Requires configured COCO pipeline options.
src/rfdetr/datasets/yolo.py Requires configured YOLO pipeline options.
src/rfdetr/datasets/o365.py Requires the square-resize option.
tests/datasets/test_builder_options.py Adds builder option contract tests.
tests/datasets/test_coco.py Supplies explicit options in existing tests.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

from rfdetr.datasets.yolo import build_roboflow_from_yolo

# The options that must come from args, with no literal fallback. Ordered as the builders read them.
REQUIRED_PIPELINE_OPTIONS = (
# Read directly rather than via getattr with a literal default: these options have no safe constant.
# patch_size, num_windows and segmentation_head are variant-dependent, and square_resize_div_64,
# multi_scale and expanded_scales all default to True on TrainConfig. An incomplete namespace must fail
# here instead of silently building a different pipeline (GitHub #N). The optional fields below keep getattr on
"""A namespace missing a pipeline option must raise, not train a silently different pipeline."""

@pytest.fixture
def partial_namespace(self, tmp_path) -> types.SimpleNamespace:
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86%. Comparing base (6674d85) to head (9b454e7).

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #1413   +/-   ##
=======================================
  Coverage       86%     86%           
=======================================
  Files          114     114           
  Lines        14880   14880           
=======================================
  Hits         12835   12835           
  Misses        2045    2045           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Borda Borda added the bug Something isn't working label Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

N-dataset_builder_option_defaults

3 participants